/***
 * @param str
 * @param req
 * @param data
 * @returns {{data: {}, status: boolean}}
 * 判断url是否为路由参数
 * 如果有路由参数则自动生成识别这个路由的正则
 * 并把正则返回
 */
module.exports=(str,req,data={})=>{
    let url = str.replace(/\//g,"<_GEM_>");
    let router = global.router[req.method.toLowerCase()];
    !router && (router={})
    req.$route_parameter={};
    let bool = Object.keys(router).some(value => {
        if(router[value].regular.test(url)){
            router[value].replace
                .reduce((par,e)=>par.replace(e,""),str)
                .split("/").filter(res=>res)
                .forEach((e,index) => {
                    req[router[value].parameter[index]]=e;
                    req.$route_parameter[router[value].parameter[index]]=e;
                });
            //把路由参数解析出来
            data=router[value];
            return true;
        }
    });
    return {
        status:bool,
        data
    }
}